22. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-07-12 04:42:36 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

22.1 Files compared

#LocationFileLast Modified
1Porto v4.0.5/Theme Files/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/Layer/FilterDecimal.php2016-09-27 16:15:52 +0000
22023-07-12 04:42:36 +0000

22.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged00
Changed00
Inserted00
Removed1153

22.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

22.4 Active regular expressions

No regular expressions were active.

22.5 Comparison detail

1 <?php    
2 /**    
3  * Copyright © 2016 Magento. All rights reserved.    
4  * See COPYING.txt for license details.    
5  */    
6 namespace Mageplaza\LayerdNavigation\Model\Layer\Filter;    
7     
8 use Magento\Catalog\Model\Layer\Filter\AbstractFilter;    
9     
10 /**    
11  * Layer decimal filter    
12  */    
13 class Decimal extends AbstractFilter    
14 {    
15     /**    
16      * @var \Magento\Framework\Pricing\PriceCurrencyInterface    
17      */    
18     private $priceCurrency;    
19     
20     /**    
21      * @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal    
22      */    
23     private $resource;    
24     
25     /**    
26      * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory    
27      * @param \Magento\Store\Model\StoreManagerInterface $storeManager    
28      * @param \Magento\Catalog\Model\Layer $layer    
29      * @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder    
30      * @param \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory    
31      * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency    
32      * @param array $data    
33      */    
34     public function __construct(    
35         \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory,    
36         \Magento\Store\Model\StoreManagerInterface $storeManager,    
37         \Magento\Catalog\Model\Layer $layer,    
38         \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder,    
39         \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory,    
40         \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,    
41         array $data = []    
42     ) {    
43         parent::__construct(    
44             $filterItemFactory,    
45             $storeManager,    
46             $layer,    
47             $itemDataBuilder,    
48             $data    
49         );    
50         $this->resource = $filterDecimalFactory->create();    
51         $this->priceCurrency = $priceCurrency;    
52     }    
53     
54     /**    
55      * Apply price range filter    
56      *    
57      * @param \Magento\Framework\App\RequestInterface $request    
58      * @return $this    
59      * @throws \Magento\Framework\Exception\LocalizedException    
60      */    
61     public function apply(\Magento\Framework\App\RequestInterface $request)    
62     {    
63         /**    
64          * Filter must be string: $fromPrice-$toPrice    
65          */    
66         $filter = $request->getParam($this->getRequestVar());    
67         if (!$filter || is_array($filter)) {    
68             return $this;    
69         }    
70     
71         list($from, $to) = explode('-', $filter);    
72     
73         $this->getLayer()    
74             ->getProductCollection()    
75             ->addFieldToFilter(    
76                 $this->getAttributeModel()->getAttributeCode(),    
77                 ['from' => $from, 'to' => $to]    
78             );    
79     
80         $this->getLayer()->getState()->addFilter(    
81             $this->_createItem($this->renderRangeLabel(empty($from) ? 0 : $from, $to), $filter)    
82         );    
83     
84         return $this;    
85     }    
86     
87     /**    
88      * Get data array for building attribute filter items    
89      *    
90      * @return array    
91      * @throws \Magento\Framework\Exception\LocalizedException    
92      * @SuppressWarnings(PHPMD.NPathComplexity)    
93      */    
94     protected function _getItemsData()    
95     {    
96         $attribute = $this->getAttributeModel();    
97     
98         /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */    
99         $productCollection = $this->getLayer()->getProductCollection();    
100         $productSize = $productCollection->getSize();    
101         $facets = $productCollection->getFacetedData($attribute->getAttributeCode());    
102     
103         $data = [];    
104         foreach ($facets as $key => $aggregation) {    
105             $count = $aggregation['count'];    
106             if (!$this->isOptionReducesResults($count, $productSize)) {    
107                 continue;    
108             }    
109             list($from, $to) = explode('_', $key);    
110             if ($from == '*') {    
111                 $from = '';    
112             }    
113             if ($to == '*') {    
114                 $to = '';    
115             }    
116             $label = $this->renderRangeLabel(    
117                 empty($from) ? 0 : $from,    
118                 empty($to) ? $to : $to    
119             );    
120             $value = $from . '-' . $to;    
121     
122             $data[] = [    
123                 'label' => $label,    
124                 'value' => $value,    
125                 'count' => $count,    
126                 'from' => $from,    
127                 'to' => $to    
128             ];    
129         }    
130     
131         return $data;    
132     }    
133     
134     /**    
135      * Prepare text of range label    
136      *    
137      * @param float|string $fromPrice    
138      * @param float|string $toPrice    
139      * @return \Magento\Framework\Phrase    
140      */    
141     protected function renderRangeLabel($fromPrice, $toPrice)    
142     {    
143         $formattedFromPrice = $this->priceCurrency->format($fromPrice);    
144         if ($toPrice === '') {    
145             return __('%1 and above', $formattedFromPrice);    
146         } else {    
147             if ($fromPrice != $toPrice) {    
148                 $toPrice -= .01;    
149             }    
150             return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));    
151         }    
152     }    
153 }